<!--
  Author: 善良的YWJ
  Created by shanliangdeYWJ on 2020/09/09
  File: 05.3解决异步设置值每个组件都是独立的.html
  Description: "
  
   请输入文件描述内容
  
               " 
  Github: https://github.com/shanliangdeYWJ
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <meta name="keywords" content="">
  <meta name="description" content="">
  <title>02JSX简介</title>
  <style></style>
</head>

<body>

  <div id="root"></div>

  <!-- 加载 React。-->
  <!-- 注意: 部署时，将 "development.js" 替换为 "production.min.js"。-->

  <script src="../js/react@16.development.js" crossorigin></script>
  <script src="../js/react-dom@16.development.js" crossorigin></script>
  <script src="../js/babel@6.min.js"></script>




  <!-- 加载我们的 React 组件。-->
  <script type="text/babel">
    // 命令式编程 用代码告诉计算机去做什么
    const root = document.getElementById("root")
    const btn = document.createElement("button")
    btn.className = "btn red"
    btn.textContent = "Demo"

    btn.onclick = function () {
      if (this.classList.contains("red")) {
        this.classList.remove("red")
        this.classList.add("blue")
      } else {
        this.classList.remove("blue")
        this.classList.add("red")
      }
    }

    root.appendChild(btn)
  </script>
</body>

</html>